//
//  XLIconTitleArrowCell.m
//  industry
//
//  Created by xl on 2020/11/24.
//  Copyright © 2020 Haier. All rights reserved.
//

#import "XLIconTitleArrowCell.h"

@interface XLIconTitleArrowCell ()

@property (nonatomic, strong) XLImageView *iconIG;
@property (nonatomic, strong) XLLabel *titleLB;
@property (nonatomic, strong) XLLabel *infoLB;
@property (nonatomic, strong) XLImageView *arrowIG;
@property (nonatomic, strong) XLView *lineView;

@end

@implementation XLIconTitleArrowCell

- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        self.selectionStyle = UITableViewCellSelectionStyleNone;
        self.backgroundColor = [UIColor whiteBgColor];
        
        [self.contentView addSubview:self.iconIG];
        [self.contentView addSubview:self.titleLB];
        [self.contentView addSubview:self.infoLB];
        [self.contentView addSubview:self.arrowIG];
        [self.contentView addSubview:self.lineView];

        [self makeConstrains];
    }
    return self;
}

- (void)makeConstrains {
    [_iconIG mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.contentView).offset(30);
        make.centerY.equalTo(self.contentView);
        make.size.mas_equalTo(CGSizeMake(20, 20));
    }];
    
    [_titleLB mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.iconIG.mas_right).offset(15);
        make.centerY.equalTo(self.contentView);
    }];
    
    [_arrowIG mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.equalTo(self.contentView).offset(-30);
        make.centerY.equalTo(self.contentView);
        make.size.mas_equalTo(CGSizeMake(9, 16));
        
    }];
    
    [_infoLB mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.equalTo(self.arrowIG.mas_left).offset(-5);
        make.centerY.equalTo(self.contentView);
    }];
    
    [_lineView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.contentView).offset(30);
        make.right.equalTo(self.contentView).offset(-30);
        make.bottom.equalTo(self.contentView);
        make.height.mas_equalTo(1);
    }];
}

#pragma mark - Public
- (void)loadCellData:(NSString *)icon
               title:(NSString *)title
                info:(NSString *)info {
    UIImage *image = XLIMAGE(icon);
    [_iconIG mas_updateConstraints:^(MASConstraintMaker *make) {
        make.size.mas_equalTo(CGSizeMake(image.size.width, image.size.height));
    }];
    _iconIG.image = image;
    _titleLB.text = title;
    _infoLB.text = info;
}

#pragma mark - setter/getter
- (XLImageView *)iconIG {
    if (!_iconIG) {
        _iconIG = [XLImageView new];
    }
    return _iconIG;
}


- (XLLabel *)titleLB {
    if (!_titleLB) {
        _titleLB = [XLLabel new];
        _titleLB.font = [UIFont fontOfPingFangSCRegularWithSize:13];
        _titleLB.textColor = [UIColor blackFontColor];
    }
    return _titleLB;
}

- (XLImageView *)arrowIG {
    if (!_arrowIG) {
        _arrowIG = [XLImageView new];
        _arrowIG.image = XLIMAGE(@"arrow");
    }
    return _arrowIG;
}

- (XLView *)lineView {
    if (!_lineView) {
        _lineView = [XLView new];
        _lineView.backgroundColor = [UIColor graySecondLineColor];
    }
    return _lineView;
}

- (XLLabel *)infoLB {
    if (!_infoLB) {
        _infoLB = [XLLabel new];
        _infoLB.font = [UIFont fontOfPingFangSCRegularWithSize:13];
        _infoLB.textColor = [UIColor grayFontColor];
    }
    return _infoLB;
}

@end
